package com.xl.myEnum;

import lombok.AllArgsConstructor;

//操作类型枚举类
@AllArgsConstructor
public enum OperationEnum {

    NONE(0,""),
    SAVE(1, "保存"),
    DELETE(2, "删除"),
    UPDATE(3, "修改"),
    QUERY(4, "查询"),
    IMPORT(5,"导入"),
    EXPORT(6, "导出"),
    LOGIN(7,"登录");

    private int type;

    private String info;

    public int getType() {
        return type;
    }

    public String getInfo() {
        return info;
    }

    public String getInfoByType(Integer type) {
        for (OperationEnum value : values()) {
            if (value.type == type){
                return value.info;
            }
        }
        throw new RuntimeException("枚举中为包含该类型");
    }

    public Integer getTypeByInfo(String typeInfo) {
        for (OperationEnum value : values()) {
            if (value.info.equals(typeInfo)) {
                return value.type;
            }
        }
        throw new RuntimeException("枚举中为包含该类型");
    }
}
